Skip to content

lesson-1.10#1

Open
zemiarsi wants to merge 1 commit intomainfrom
lesson-1.10
Open

lesson-1.10#1
zemiarsi wants to merge 1 commit intomainfrom
lesson-1.10

Conversation

@zemiarsi
Copy link
Owner

@zemiarsi zemiarsi commented Nov 3, 2021

No description provided.

Copy link

@kaytijackson97 kaytijackson97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking really nice! Well done converting those components into functional components! Remember that you can import useState and other hooks from react to clean up your code and to keep good indentation

import React from "react";
import Button from "./Button";
function GuessControl({ onGuess }) {
const [currentGuess, setCurrentGuess] = React.useState('');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can import useState from react to prevent from re-writing React

const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber());
const[numberOfGuesses, setNumberOfGuesses]= React.useState(0);
const[latestGuess, setLatestGuess]= React.useState(null);
function handleGuess(guess) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix indentation to match state variable indentation

const isCorrectGuess = this.state.latestGuess === this.state.numberToGuess;

function NumberGuessingGame() {
const[numberToGuess, setNumberToGuess]= React.useState(getRandomNumber());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can import useState like mentioned above

@zemiarsi
Copy link
Owner Author

zemiarsi commented Nov 11, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants